import request from '@/utils/request'

/**
 * 专栏相关API
 */

// 创建专栏
export function createColumn(data) {
  return request({
    url: '/column/create',
    method: 'post',
    data
  })
}

// 更新专栏信息
export function updateColumn(columnId, data) {
  return request({
    url: `/column/${columnId}`,
    method: 'put',
    data
  })
}

// 获取专栏详情
export function getColumnDetail(columnId) {
  return request({
    url: `/column/${columnId}`,
    method: 'get'
  })
}

// 分页查询专栏列表
export function getColumnList(data) {
  return request({
    url: '/column/list',
    method: 'post',
    data
  })
}

// 获取热门专栏
export function getHotColumns(limit = 10) {
  return request({
    url: '/column/hot',
    method: 'get',
    params: { limit }
  })
}

// 关注/取消关注专栏
export function toggleFollowColumn(columnId) {
  return request({
    url: `/column/${columnId}/follow`,
    method: 'post'
  })
}

// 获取专栏文章列表
export function getColumnArticles(columnId, data) {
  return request({
    url: `/column/${columnId}/articles`,
    method: 'post',
    data
  })
}

// 删除专栏
export function deleteColumn(columnId) {
  return request({
    url: `/column/${columnId}`,
    method: 'delete'
  })
}
